package com.ruoyi.web.pojo.dto.stock;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * 出库明显对象 retrieval
 * 
 * @author zq
 * @date 2024-01-08
 */
@Data
@NoArgsConstructor
public class RetrievalExcel
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @Excel(name ="记录账户")
    private String userId;

    /** 创建者 */
    @Excel(name ="账户名称")
    private String createBy;
    /** 产品类型 */
    @Excel(name = "产品类型")
    private String type;
    /** 产品名称 */
    @Excel(name = "产品名称")
    private String product;



    /** 数量 */
    @Excel(name = "数量")
    private Float number;

    /** 单位 */
    @Excel(name = "单位")
    private String unit;

    @Excel(name = "出库去向")
    private String whereabouts;
    /** 创建时间 */
    @Excel(name = "入库日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private String createTime;


    public  RetrievalExcel (RetrievalRep retrieval) {
        if (Objects.isNull(retrieval)){
            return;
        }
        this.setUserId(retrieval.getUserId());
        switch (retrieval.getType()){
            case "1":
                this.setType("农资");
                break;
            case "2":
                this.setType("农产品");
                break;
            case "3":
                this.setType("机械设备");
                break;
            case "4":
                this.setType("其他");
                break;
        }
        this.setProduct(retrieval.getProduct());
        this.setNumber(retrieval.getNumber());
        this.setUnit(retrieval.getUnit());
        this.setWhereabouts(retrieval.getWhereabouts());
        this.setCreateBy(retrieval.getCreateBy());
        if (Objects.nonNull(retrieval.getCreateTime())){
            this.setCreateTime(DateUtils.getConvertFormat(retrieval.getCreateTime()));
        }

    }
}
